package com.atguigu.guli.service.edu.admin;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.vo.ExcelSubjectVo;
import com.atguigu.guli.service.edu.listener.ExcelSubjectListener;
import com.atguigu.guli.service.edu.mapper.SubjectMapper;
import com.atguigu.guli.service.edu.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Miluo
 * @since 2020-10-14
 */
@Api(tags = "课程分类管理")
@RestController

@RequestMapping("/admin/edu/subject")
public class AdminSubjectController {
    @Autowired(required = true)
    SubjectService subjectService;


    @ApiOperation("课程列表分类")
    @GetMapping("/nested-list")
    public R subjectList(){
        List<ExcelSubjectVo> subjectVoList = subjectService.subjectList();
        return R.ok().data("items",subjectVoList);
    }

    @ApiOperation("批量导入")
    @PostMapping("/import")
    public R ExcelImport(MultipartFile file){
        String originalFilename = file.getOriginalFilename();
        System.out.println(originalFilename);
        subjectService.saveExcelSubject(file);
        return R.ok();
    }
}

